Add Lua rockspec package handler for LuaRocks dependencies#4743
Add Lua rockspec package handler for LuaRocks dependencies#4743SLASH217 wants to merge 9 commits intoaboutcode-org:developfrom
Conversation
Implement base handler class and Lua rockspec parser using luaparser for AST-based dependency extraction. Signed-off-by: Prashanna Dahal <prashanna217@gmail.com>
Extract package metadata and dependencies from rockspec files with version specification parsing. Signed-off-by: Prashanna Dahal <prashanna217@gmail.com>
* Test parser with real Kong rockspec file * Test handler integration with patterns Signed-off-by: Prashanna Dahal <prashanna217@gmail.com>
Register handler in APPLICATION_PACKAGE_DATAFILE_HANDLERS to enable automatic .rockspec file detection. Signed-off-by: Prashanna Dahal <prashanna217@gmail.com>
* Update contributing-docs link to new structure * Ensure both documentation links work correctly * Point to getting-started/contribute path Signed-off-by: Prashanna Dahal <prashanna217@gmail.com>
35fb9e2 to
c84c872
Compare
Change luaparser from == to match project's version pinning pattern: * requirements.txt: luaparser==1.4.3 (exact pinning) * setup.cfg: luaparser == 1.4.3 (exact pinning) Signed-off-by: Prashanna Dahal <prashanna217@gmail.com>
c84c872 to
3b359de
Compare
Signed-off-by: Prashanna Dahal <prashanna217@gmail.com>
- This was causing a test to fail in CI/CD Signed-off-by: Prashanna Dahal <prashanna217@gmail.com>
- Extra "/n" causing failure of CI/CD Signed-off-by: Prashanna Dahal <prashanna217@gmail.com>
AyanSinhaMahapatra
left a comment
There was a problem hiding this comment.
Thanks++ @SLASH217 for the PR, looking good already, but you need to modify the tests so we can see the full output and verify the functionality added before I can do an in depth review. Added some other feedback you also need to address.
| parser = rockspec.RockspecParser(test_file) | ||
| data = parser.parse() | ||
|
|
||
| assert data['rockspec_format'] == '3.0' |
There was a problem hiding this comment.
This is not how we write tests for package manifest parsers, asserting the data one by one. Instead we dump the whole results in a JSON file and check the output matches to it, so we can see the entire output and test it, and not just some fields. And this result is more readable, and for changes we can regen and check the changes in output.
This is done using tests.packagedcode.packages_test_utils.Packagetester.check_packages_data()
See how this is done in all other test files for package manifest parsers, for example:
| build = { | ||
| type = "builtin", | ||
| modules = { | ||
| ["kong"] = "kong/init.lua", |
There was a problem hiding this comment.
AFAIK we are not parsing/storing the modules info here and this is increasing the test file size without contributing anything to the test, can you remove these modules from all the tests?
There was a problem hiding this comment.
Same for all non essential things in other test files.
| @@ -0,0 +1,530 @@ | |||
| package = "kong" | |||
There was a problem hiding this comment.
Would be great to add the link to this test file (and all others) as a comment, since these are real files(?) and we should provide where we got them from
| - name: Package name | ||
| - version_number: Clean version number (e.g. "3.1.3") or None | ||
| - version_spec: Full version specification with operator (e.g. "== 3.1.3") or None | ||
| - raw: Original input string |
There was a problem hiding this comment.
Not sure why you want to pass back the input, don't we already have this in context?
| package_name: Name of the package | ||
| package_version: Optional version string (without operators) | ||
|
|
||
| Returns: |
There was a problem hiding this comment.
This is additional information you're conveying twice, and not how we write the docstrings. Just describe the output, what it does and the inputs in a short to-the-point docstring. For all the functions
| extra_data['supported_platforms'] = platforms | ||
|
|
||
| # Future fields can be added here | ||
| # e.g., build_backend, build_requires, etc. |
There was a problem hiding this comment.
Why not just add these now? And if you're keeping work for later, add a TODO:
| jsonstreams >= 0.5.0 | ||
| license_expression >= 30.4.4 | ||
| lxml >= 5.4.0 | ||
| luaparser == 4.0.0 |
There was a problem hiding this comment.
Let's not pin dependencies, you can add this as a lower bound. We are a library too :)
| keyring==23.7.0 | ||
| license-expression==30.4.4 | ||
| lxml==6.0.2 | ||
| luaparser==4.0.0 |
There was a problem hiding this comment.
This is also installing two new dependencies, can you also add these here?
https://github.com/boolangery/py-lua-parser/blob/master/setup.py#L29
|
|
||
| git checkout -b name-of-your-bugfix-or-feature | ||
|
|
||
| 4. Check out the Contributing to Code Development `documentation <https://scancode-toolkit.readthedocs.io/en/stable/contribute/contrib_dev.html>`_, as it contains more in-depth guide for contributing code and documentation. |
There was a problem hiding this comment.
Thanks for catching and fixing this!
Add Lua rockspec package handler for LuaRocks dependencies
Fixes #3526
Changes
RockspecHandlerclass for .rockspec file detectionRockspecParserusing Lua AST parsing with luaparser libraryAPPLICATION_PACKAGE_DATAFILE_HANDLERSregistryTasks
Run tests locally to check for errors.
Signed-off-by: Prashanna Dahal prashanna217@gmail.com